/* This file is part of the Pardus Economy Planner.

   The Pardus Economy Planner is free software: you can redistribute it
   and/or modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation, either version 3 of
   the License, or (at your option) any later version.

   The Pardus Economy Planner is distributed in the hope that it
   will be useful, but WITHOUT ANY WARRANTY; without even the implied
   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   See the GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with the Pardus Economy Planner.  If not, see
   <http://www.gnu.org/licenses/>.
*/

/* Utility scripts for Pardus Sector Tool
 * (C) Yassen 2010
 *
 * sector.js
 * Defines functions for sectors.
 *
 * Functions:
 * Export(id)
 * Import(id, code)
 * Draw(id)
 * Clear(id)
 */

Utility.Sector.MapToTiles = function(code)
{
  var parts = code.split("|");
  var dim = parts[1].split("X");
  var width = dim[0] * 1;
  var height = dim[1] * 1;
  var data = parts[0];

  var tiles = [];
  var i = 0;

  for (var y = 0; y <= height; y++)
  {
    for (var x = 0; x <= width; x++)
    {
      tiles.push(new Tile(i, x, y, AbbrToTileType(data[i]), false));
      i++;
    }
  }

  return tiles;
}

Global.CachedMaps["PI 4-669"] = Utility.Sector.MapToTiles("bbbeeebbbbbbefebbbbbbeeebbbbbbbebbeebbeeeeeeebeeffffeeeeffeeeebeefeebeeebeeebbeeebbeebbbee|8X9");